using System;
using Cfg.Exceptions;

namespace Cfg.ValidationAttributes
{
    public class RequiredAttribute : CfgFinalizedStringValueValidatorBaseAttribute
    {
        public RequiredAttribute(params string[] contexts)
        {
            Contexts = contexts;
        }

        protected override void Validate(string finalizedStringValue)
        {
            if (string.IsNullOrEmpty(finalizedStringValue))
                throw new ValueNotFoundException("Field is required, but value was not found");
        }
    }
}